﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="EditCatalog.aspx.cs" Inherits="CourseScheduling.EditCatalog" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <table width=100%>
     <tr valign=top>
    <td class=style1>
        <asp:Button ID="NewCourseInfo" runat="server" onclick="insertNewCourse_click" 
            Text="Insert New Course Information" />
         </td>
        <td>
            
            &nbsp;</td>
    </tr>
    <tr valign=top>
    <td class=style1>
        <asp:SqlDataSource ID="CourseSource" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" 
            DeleteCommand="DELETE FROM [Course] WHERE [CourseNumber] = @CourseNumber" 
            InsertCommand="INSERT INTO [Course] ([CourseNumber], [CourseName], [OddFall], [EvenSpring], [EvenFall], [OddSpring]) VALUES (@CourseNumber, @CourseName, @OddFall, @EvenSpring, @EvenFall, @OddSpring)" 
            SelectCommand="SELECT * FROM [Course]" 
            UpdateCommand="UPDATE [Course] SET [CourseName] = @CourseName, [OddFall] = @OddFall, [EvenSpring] = @EvenSpring, [EvenFall] = @EvenFall, [OddSpring] = @OddSpring WHERE [CourseNumber] = @CourseNumber">
            <DeleteParameters>
                <asp:Parameter Name="CourseNumber" Type="String" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="CourseNumber" Type="String" />
                <asp:Parameter Name="CourseName" Type="String" />
                <asp:Parameter Name="OddFall" Type="Boolean" />
                <asp:Parameter Name="EvenSpring" Type="Boolean" />
                <asp:Parameter Name="EvenFall" Type="Boolean" />
                <asp:Parameter Name="OddSpring" Type="Boolean" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="CourseName" Type="String" />
                <asp:Parameter Name="OddFall" Type="Boolean" />
                <asp:Parameter Name="EvenSpring" Type="Boolean" />
                <asp:Parameter Name="EvenFall" Type="Boolean" />
                <asp:Parameter Name="OddSpring" Type="Boolean" />
                <asp:Parameter Name="CourseNumber" Type="String" />
            </UpdateParameters>
        </asp:SqlDataSource>
        <br />
        <asp:GridView ID="GridView1" runat="server" AllowSorting="True" 
            AutoGenerateColumns="False" CellPadding="4" 
            DataKeyNames="CourseNumber" DataSourceID="CourseSource" 
            ForeColor="#333333" GridLines="None">
            <AlternatingRowStyle BackColor="White" />
            <Columns>
                <asp:CommandField HeaderText="Action" 
                    ShowEditButton="True" />
                <asp:BoundField DataField="CourseNumber" HeaderText="Course Number" 
                    ReadOnly="True" SortExpression="CourseNumber" />
                <asp:BoundField DataField="CourseName" HeaderText="Course Name" 
                    SortExpression="CourseName" />
                <asp:CheckBoxField DataField="OddFall" HeaderText="Odd Fall" 
                    SortExpression="OddFall" />
                <asp:CheckBoxField DataField="EvenSpring" HeaderText="Even Spring" 
                    SortExpression="EvenSpring" />
                <asp:CheckBoxField DataField="EvenFall" HeaderText="Even Fall" 
                    SortExpression="EvenFall" />
                <asp:CheckBoxField DataField="OddSpring" HeaderText="Odd Spring" 
                    SortExpression="OddSpring" />
            </Columns>
            <EditRowStyle BackColor="#2461BF" />
            <FooterStyle BackColor="#507CD1" ForeColor="White" Font-Bold="True" />
            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
            <RowStyle BackColor="#EFF3FB" />
            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
            <SortedAscendingCellStyle BackColor="#F5F7FB" />
            <SortedAscendingHeaderStyle BackColor="#6D95E1" />
            <SortedDescendingCellStyle BackColor="#E9EBEF" />
            <SortedDescendingHeaderStyle BackColor="#4870BE" />
        </asp:GridView>
        <br />
        </td>
        <td>  </td>
        <td>
            
            <asp:SqlDataSource ID="CourseProgSource" runat="server" 
                ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" 
                DeleteCommand="DELETE FROM [CourseProgJunction] WHERE [CourseNumber] = @CourseNumber AND [ProgramID] = @ProgramID" 
                InsertCommand="INSERT INTO [CourseProgJunction] ([CourseNumber], [ProgramID]) VALUES (@CourseNumber, @ProgramID)" 
                SelectCommand="SELECT * FROM [CourseProgJunction]">
                <DeleteParameters>
                    <asp:Parameter Name="CourseNumber" Type="String" />
                    <asp:Parameter Name="ProgramID" Type="String" />
                </DeleteParameters>
                <InsertParameters>
                    <asp:Parameter Name="CourseNumber" Type="String" />
                    <asp:Parameter Name="ProgramID" Type="String" />
                </InsertParameters>
            </asp:SqlDataSource>
            <br />
            <asp:GridView ID="GridView2" runat="server" AllowSorting="True" 
                AutoGenerateColumns="False" CellPadding="4" 
                DataKeyNames="CourseNumber,ProgramID" DataSourceID="CourseProgSource" 
                ForeColor="#333333" GridLines="None">
                <AlternatingRowStyle BackColor="White" />
                <Columns>
                    <asp:CommandField HeaderText="Remove" ShowDeleteButton="True" />
                    <asp:BoundField DataField="CourseNumber" HeaderText="Course Number" 
                        ReadOnly="True" SortExpression="CourseNumber" />
                    <asp:BoundField DataField="ProgramID" HeaderText="Program ID" ReadOnly="True" 
                        SortExpression="ProgramID" />
                </Columns>
                <EditRowStyle BackColor="#2461BF" />
                <FooterStyle BackColor="#507CD1" ForeColor="White" Font-Bold="True" />
                <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                <RowStyle BackColor="#EFF3FB" />
                <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                <SortedAscendingCellStyle BackColor="#F5F7FB" />
                <SortedAscendingHeaderStyle BackColor="#6D95E1" />
                <SortedDescendingCellStyle BackColor="#E9EBEF" />
                <SortedDescendingHeaderStyle BackColor="#4870BE" />
            </asp:GridView>
            
        </td>
    </tr>
   
    </table>
</asp:Content>
